
//非对称之美
//输入一个字符串，返回最长非回文子字符串的长度
int main()
{
    string str = "";
    cin >> str;
    bool flag = false;
    int left = 0, right = str.length() - 1;
    int maxLen = 0;
    while (left <= right)
    {
        if (str[left] == str[right])
        {
            if (str[left] != str[0] || str[right] != str[0])
            {
                flag = true;
            }
            ++left, --right;
        }
        else
        {
            maxLen = str.length();
            break;
        }
    }
    if (!maxLen)
    {
        if (flag)
        {
            maxLen = str.length() - 1;
        }
    }
    cout << maxLen;
    return 0;
}